#include "StdAfx.h"
#include "ADSR.h"


CADSR::CADSR(void)
{
	mDecay = 0.;
	mSustain = 0.;
	mRelease = 0.;

	mDuration = 0.;
	mTime = 0.;
	
	mSource = NULL;
}


CADSR::~CADSR(void)
{
}

void CADSR::Start( void )
{
	mTime = 0.0;
	double lBps = 1 / ( GetBPM() / 60 );
	mDecay = mDuration * 0.05 * lBps;
	mSustain = mDuration * 0.1 * lBps;
	mRelease =mDuration * 0.15 * lBps;
	mState = Attack;

}

bool CADSR::Generate( void )
{
	mTime += GetSamplePeriod();

	return true;
}